<?php


namespace App\library\services;


use App\library\common\Curl;
use App\Models\NewHouse;

class NewHouseService extends BaseServices
{
    /**
     * Author:YangXinPeng
     * 百度获取经纬度
     * @param $address
     * @return mixed
     */
    public static function geocoding($address)
    {
        $url = sprintf(config('setting.location'), $address);
        $data = Curl::geturl($url);
        return $data;
    }


    /**
     * Author:YangXinPeng
     * 根据楼盘ID获取户型信息
     * @param $id
     * @return array
     */
    public static function getDataByBid($id)
    {
        if (empty($id)){
            return self::fail('参数错误');
        }
        $data = NewHouse::with(['building','houseType','forward','fitUp'])
            ->where('building_id',$id)
            ->get();
        $data && $data = $data->toArray();
        return self::success('成功',$data);
    }
}
